
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

# Cross-compile options
if(DEFINED CROSS_PREFIX)
  set(CROSS_TOOLCHAIN_PREFIX ${CROSS_PREFIX})
  set(CMAKE_CXX_COMPILER "${CROSS_TOOLCHAIN_PREFIX}g++")
  set(CMAKE_C_COMPILER "${CROSS_TOOLCHAIN_PREFIX}gcc")
endif()

set(COMMON_COMPILER_FLAG "-Wall -fPIC -fvisibility=hidden")
#若没有指定CMAKE_BUILD_TYPE，默认开O2优化。否则，由cmake自动决定优化等级
if(NOT CMAKE_BUILD_TYPE)
  set(COMMON_COMPILER_FLAG "${COMMON_COMPILER_FLAG} -O2")
endif()

set(CMAKE_C_FLAGS "${COMMON_COMPILER_FLAG} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${COMMON_COMPILER_FLAG} ${CMAKE_CXX_FLAGS}")
